package com.wang.wemedia.controller.v1;

import com.wang.common.model.dto.ResponseResult;
import com.wang.wemedia.api.model.dto.WmChannelPageDTO;
import com.wang.wemedia.api.model.pojo.WmChannel;
import com.wang.wemedia.service.WmChannelService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 频道信息接口，系统将所有频道缓存到数据库中，查询所有频道信息
 *
 * @author: wangning
 * @date: 2024/1/12 10:22
 */
@RestController
@RequestMapping("/api/v1/channel")
@RequiredArgsConstructor
public class WmchannelController {

    private final WmChannelService wmChannelService;

    /**
     * 新增频道
     *
     * @param wmChannel
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmChannel wmChannel){
        return wmChannelService.add(wmChannel);
    }

    /**
     * 删除频道
     *
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id){
        return wmChannelService.delete(id);
    }

    /**
     * 修改
     *
     * @param wmChannel
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannel wmChannel){
        return wmChannelService.alter(wmChannel);
    }

    /**
     * 分页列表
     *
     * @return
     */
    @PostMapping("/list")
    public ResponseResult listWmChannel(@RequestBody WmChannelPageDTO wmChannelPageDTO){
        return wmChannelService.listWmChannel(wmChannelPageDTO);
    }

    /**
     * 查询所有频道
     *
     * @return
     */
    @GetMapping("/channels")
    public ResponseResult findAll(){
        return wmChannelService.findAll();
    }

}
